package com.umeox.watch.moto.launcher.ui;

import android.os.Bundle;
import android.os.Handler;

import com.umeox.moto.watch.themes.app.ThemeAppCompatActivity;
import com.umeox.moto.watch.themes.widget.TextView;
import com.umeox.watch.moto.launcher.BaseApplication;
import com.umeox.watch.moto.launcher.R;
import com.umeox.watch.moto.launcher.widget.BatteryCircleView;

import java.util.Locale;


public class ChargingActivity extends ThemeAppCompatActivity {


    private BatteryCircleView mProgressView;
    private TextView mBatteryTv;

	private final Handler handler = new Handler(msg -> {
        ChargingActivity.this.finish();

        return false;
    });
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.charging_activity);
        mProgressView = findViewById(R.id.battery_progress);
        mBatteryTv = findViewById(R.id.tv_battery);
        int battery = BaseApplication.getInstance().getBatteryLevel();
        mBatteryTv.setText(String.format(Locale.ENGLISH,"%d%%", battery));
        float percent = (float) battery / 100;
        mProgressView.setBatteryProgress(battery);

        handler.sendEmptyMessageDelayed(0,3000);
	}

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if(handler!=null){
            handler.removeMessages(0);
        }
    }
}
